import java.util.Arrays;
import java.util.Comparator;
import java.util.Vector;

public class Test {
    public String largestNumber(int[] nums) {
        // 1.优化,把所有的数转成字符串
        int n = nums.length;
        String[] strs = new String[n];
        for (int i = 0; i < n; i++) {
            strs[i] = String.valueOf(nums[i]);
        }
        //排序
        Arrays.sort(strs, new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return (o2+o1).compareTo(o1+o2);
            }
        });
        //提取结果
        StringBuilder ret = new StringBuilder();
        for(String s:strs) {
            ret.append(s);
        }
        if(ret.charAt(0) == '0') return "0";
        return ret.toString();
    }
}
